package com.billdowney.entity.user;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import org.hibernate.annotations.Type;

import com.billdowney.entity.base.BaseEntityIdByUUIDHex;

import io.swagger.annotations.ApiModelProperty;

/**
 * @ClassName: UserLoginRecord
 * @Description: 用户登录记录
 * @author 超级小富翁 - BillDowney
 * @date 2018年2月24日 下午5:20:55
 */
@Entity
@Table(name = "user_login_record")
public class UserLoginRecord extends BaseEntityIdByUUIDHex {

	private static final long serialVersionUID = 676943668707380114L;

	@ApiModelProperty(value = "IP地址")
	@Column(length = 46)
	private String ip;
	@ApiModelProperty(value = "地址")
	@Column(length = 200)
	private String address;
	@ApiModelProperty(value = "登录状态", notes = "一般为：用户登录、用户登出、用户被强制下线、用户多设备登录、登录超时自动下线")
	@Enumerated(EnumType.STRING)
	@Column(length = 20)
	private UserLoginRecordStatus loginStatus;
	@ApiModelProperty(value = "客户端", notes = "一般为：网页、安卓、苹果、电脑客户端")
	@Column(length = 50)
	private String client;
	@ApiModelProperty(value = "客户端信息", notes = "request中user-agent的值")
	@Type(type = "text")
	private String clientInfo;
	@ApiModelProperty(value = "SessionId", notes = "登录时的SessionId")
	@Column(length = 100)
	private String requestedSessionId;

	@ManyToOne(targetEntity = UserInfo.class, cascade = { CascadeType.MERGE,
			CascadeType.REFRESH }, fetch = FetchType.EAGER)
	@JoinColumn(name = "userInfo_id")
	@ApiModelProperty(value = "用户信息")
	private UserInfo userInfo;

	public String getIp() {
		return ip;
	}

	public void setIp(String ip) {
		this.ip = ip;
	}

	public String getAddress() {
		return address;
	}

	public void setAddress(String address) {
		this.address = address;
	}

	public UserLoginRecordStatus getLoginStatus() {
		return loginStatus;
	}

	public void setLoginStatus(UserLoginRecordStatus loginStatus) {
		this.loginStatus = loginStatus;
	}

	public String getClient() {
		return client;
	}

	public void setClient(String client) {
		this.client = client;
	}

	public String getClientInfo() {
		return clientInfo;
	}

	public void setClientInfo(String clientInfo) {
		this.clientInfo = clientInfo;
	}

	public String getRequestedSessionId() {
		return requestedSessionId;
	}

	public void setRequestedSessionId(String requestedSessionId) {
		this.requestedSessionId = requestedSessionId;
	}

	public UserInfo getUserInfo() {
		return userInfo;
	}

	public void setUserInfo(UserInfo userInfo) {
		this.userInfo = userInfo;
	}

}
